package com.hws.leetcode.Day_01_08;

import java.util.Arrays;

/**
 * ClassName:leetcode_300
 * Package:com.hws.leetcode.Day_01_08
 * Description:最长递增子序列
 *
 * @ date:2022/1/8 13:36
 * @ author:hws
 */
public class leetcode_300 {

    public int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                }
            }
        }
        int res = 0;
        for (int i = 0; i < dp.length; i++) {
            res = Math.max(res, dp[i]);
        }
        return res;
    }

    public static void main(String[] args) {
        leetcode_300 lc = new leetcode_300();
        int[] nums = {1, 2, 3, 1, 2, 9};
        System.out.println(lc.lengthOfLIS(nums));
    }
}
